package bradd.tom;

import android.app.Activity;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.SimpleCursorAdapter;
import android.widget.Spinner;

public class Setup extends Activity {
	
	
	ArrayAdapter<CharSequence> adapter;
	public String calName;



@Override 
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.setup);
    


    
    Spinner calname = (Spinner)findViewById(R.id.calnamespin);
    String[] projection = new String[] { "_id", "name" };
    Uri calendars = Uri.parse("content://calendar/calendars");     
    Cursor managedCursor =
       managedQuery(calendars, projection,
       "selected=1", null, null);
    
    if (managedCursor.moveToFirst()) {
    	 
    	 String calId; 
    	 int nameColumn = managedCursor.getColumnIndex("name"); 
    	 int idColumn = managedCursor.getColumnIndex("_id");
    	 do {
    	    calName = managedCursor.getString(nameColumn);
    	    calId = managedCursor.getString(idColumn);
    	 } while (managedCursor.moveToNext());
    	}

    SimpleCursorAdapter adapter2 = new SimpleCursorAdapter(this,
    	    android.R.layout.simple_spinner_item, managedCursor, new String[] {calName}, new int[] {android.R.id.text1});
    adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    calname.setAdapter(adapter2);





	
}
}
